package org.snail.attendence.service.push;

import lombok.extern.log4j.Log4j;
import org.snail.activemq.PushService;
import org.snail.attendence.service.message.AttendenceMessageCreator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;

@Log4j
@Service
@Scope("prototype")
public class AttendenceInfoPushService implements PushService{

    @Autowired
    private JmsTemplate jmsTemplate;
    @Autowired
    @Qualifier("attendenceSenderQueue")
    private Destination destination;

    @Override
    public void push(Object sendObject) {
        AttendenceMessageCreator messageCreator = new AttendenceMessageCreator();
        //创建消息执行者
        messageCreator.setSendObject(sendObject);
        //推送消息到队列
        jmsTemplate.send(destination, messageCreator);
    }
}